package com.lantosec.hmrp.modules.workflow.vo;

import com.lantosec.hmrp.modules.sysdata.entity.SysDataProcess;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;

import java.util.Date;

/**
 * 流程实例历史记录
 *
 * @author lichaowei
 * @date 2020/4/30
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "流程实例历史记录信息", description = "流程实例历史记录信息")
public class HisProcessInstanceVO {

    public HisProcessInstanceVO(HistoricProcessInstance entity){
        id = entity.getId();
        processInstanceId = entity.getSuperProcessInstanceId();
        processInstanceName = entity.getName();
        deploymentId = entity.getDeploymentId();
        processDefinitionId = entity.getProcessDefinitionId();
        processDefinitionKey = entity.getProcessDefinitionKey();
        processDefinitionName = entity.getProcessDefinitionName();
        businessKey = entity.getBusinessKey();
        startUserId = entity.getStartUserId();
        startTime = entity.getStartTime();
        endTime = entity.getEndTime();
    }

    public HisProcessInstanceVO(SysDataProcess entity){
        id = entity.getDataProcessId();
        processInstanceId = entity.getProInsId();
        processInstanceName = entity.getProInsName();
        deploymentId = "";
        processDefinitionId = entity.getProcessDefinitionId();
        processDefinitionKey = "";
        processDefinitionName = "";
        businessKey = entity.getDataId();
        startUserId = entity.getStartUserId();
        startTime = entity.getCreateTime();
        endTime = entity.getFinishTime();
        taskId = entity.getCurrentTaskId();
        taskName = entity.getCurrentTaskName();
    }

    @ApiModelProperty(value = "历史记录ID")
    private String id;

    @ApiModelProperty(value = "流程实例ID")
    private String processInstanceId;

    @ApiModelProperty(value = "流程实例名称")
    private String processInstanceName;

    @ApiModelProperty(value = "流程部署Id")
    private String deploymentId;

    @ApiModelProperty(value = "流程定义Id")
    private String processDefinitionId;

    @ApiModelProperty(value = "流程定义Key")
    private String processDefinitionKey;

    @ApiModelProperty(value = "流程定义名称")
    private String processDefinitionName;

    @ApiModelProperty(value = "业务参数Key，数据表格Id")
    private String businessKey;

    @ApiModelProperty(value = "流程启动人")
    private String startUserId;

    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    private Date endTime;

    @ApiModelProperty(value = "任务Id")
    private String taskId;

    @ApiModelProperty(value = "任务名称")
    private String taskName;
}
